<template>
  <div>
    <h1>挑拨单</h1>
    <el-form :inline="true" :model="page" class="demo-form-inline">
      <el-form-item label="单据编号">
        <el-input v-model="page.documentNumber" placeholder="单据编号"></el-input>
      </el-form-item>
      <el-form-item label="批次号">
        <el-input v-model="page.batchNumber" placeholder="批次号"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="list">查询</el-button>
        <el-button type="primary" @click="toaddPro">添加</el-button>
      </el-form-item>
    </el-form>
    <el-table
        :data="tableData"
        border
        style="width: 100%">
      <el-table-column
          fixed
          prop="documentNumber"
          label="单据编号"
          width="150">
      </el-table-column>
      <el-table-column
          prop="tname"
          label="仓库"
          width="120">
      </el-table-column>
      <el-table-column
          prop="batchNumber"
          label="批次号"
          width="120">
      </el-table-column>
      <el-table-column
          prop="type"
          label="出入库类型"
          width="120">
        <template v-slot="s">
          <el-tag v-if="s.row.type==1">挑拨</el-tag>
        </template>
      </el-table-column>
      <el-table-column
          prop="remark"
          label="备注"
          width="300">
      </el-table-column>
      <el-table-column
          prop="status"
          label="状态"
          width="120">
        <template v-slot="s">
          <el-tag v-if="s.row.status==0">未提交</el-tag>
          <el-tag v-if="s.row.status==1">审批中</el-tag>
          <el-tag v-if="s.row.status==2">已完成</el-tag>
        </template>
      </el-table-column>
      <el-table-column
          prop="indate"
          label="出入库时间"
          width="120">
      </el-table-column>
      <el-table-column
          fixed="right"
          label="操作"
          width="100">
        <template slot-scope="scope">
          <el-button v-if="scope.row.status==0" @click="tosumbit(scope.row.id)" type="text" size="small">提交审批</el-button>
          <el-button v-if="scope.row.status==0" @click="toupdate(scope.row)" type="text" size="small">修改</el-button>
          <el-button v-if="scope.row.status==0" @click="del(scope.row.id)" type="text" size="small">删除</el-button>
          <el-button v-if="scope.row.status==1" @click="updatedel(scope.row.id)" type="text" size="small">撤销申请</el-button>
          <el-button v-if="scope.row.status==1 || scope.row.status==2" @click="liucheng(scope.row.id)" type="text" size="small">流程信息</el-button>
          <el-button v-if="scope.row.status==1 || scope.row.status==2" @click="seePro(scope.row.id)" type="text" size="small">查看</el-button>
        </template>
      </el-table-column>
    </el-table>

    <el-pagination
        @current-change="gopage"
        :current-page.sync="page.pageNum"
        :page-size="page.pageSize"
        layout="total, prev, pager, next"
        :total="total">
    </el-pagination>
  </div>
</template>

<script>
export default {
  name: "ProvokeView",
  data(){
    return{
      tableData:[],
      page:{
        pageNum:1,
        pageSize:3,
      },
      total:1,
    }
  },methods:{
    toupdate(){
      this.$router.push("/addpro");
    },
    del(id){
      this.axios.post("/provoke/del?id="+id).then(()=>{
        this.$message.success("删除成功");
        this.list();
      })
    },
    toaddPro(){
      this.$router.push("/addpro");
    },
    updatedel(id){
      this.axios.post("/provoke/updatedel?id="+id).then(()=>{
        this.$message.success("撤销成功");
        this.list();
      })
    },
    tosumbit(id){
      this.axios.post("/provoke/submitpro?id="+id).then(()=>{
        this.$message.success("提交成功");
        this.list();
      })
    },
    gopage(pageNum){
      this.page.pageNum=pageNum;
      this.list();
    },
    list(){
      this.axios.post("/provoke/list",this.page).then(res=>{
        this.tableData=res.data.data.list;
        this.total=res.data.data.total;
      })
    }
  },created() {
      this.list();
  }
}
</script>

<style scoped>

</style>